﻿<%@ WebHandler Language="C#" Class="service_businessservice" %>

using System;
using System.Web;
using System.Web.UI;
using JoyTalq.Core.Business;
using JoyTalq.Core.Business.Service;
using JoyTalq.Core.Business.Domain;
using System.Collections.Generic;

public class service_businessservice : BaseAjaxService, IHttpHandler
{
    #region Fields
    private BusinessFactory m_BusinessFactory = new BusinessFactory();
    private IBusinessService m_BusinessService;
    private bool m_IsRegisted = false;
    #endregion

    #region PageEvent
    public override Page RegisterMethods()
    {       
        if (m_BusinessService == null)
        {
            m_BusinessService = m_BusinessFactory.GetBusinessService();
        }
        if (!m_IsRegisted)
        {
            #region 註冊Method
            InsertMethod(this, "getallcustomerlist", "GetAllCustomerList");
            #endregion

            m_IsRegisted = true;
        }
        return this;
    }
    #endregion

    #region Methods 實做

    public void GetAllCustomerList()
    {
        try
        {
            IList<CustomerVO> customerListAll = m_BusinessService.GetAllCustomerList();

            AjaxHelper.WriteAjaxResult(true, null, customerListAll);
        }
        catch (Exception ex)
        {
            AjaxHelper.WriteAjaxError(ex.Message, ex);
        }
    }
    
    #endregion
}